package com.jdbc.connection;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
import java.util.Properties;

/**
 * @author wzm
 * @create 2023-10-31 11:21
 * project_name:web2310
 */
//测试连接池获取连接
public class Conn03 {
    public static void main(String[] args) throws Exception {
        //加载德鲁伊的配置信息
        Properties properties = new Properties();
        properties.load(Conn03.class.getClassLoader().getResourceAsStream("druid.properties"));
        //父类类型 子类对象 获取德鲁伊的实现的datasource对象
       DataSource dataSource = DruidDataSourceFactory.createDataSource( properties);
       //调用获取连接的方法获取连接对象
        Connection connection = dataSource.getConnection();
        System.out.println(connection);

//        connection.close();
    }
}
